package bluejack.game.gal.diaplay;
import nme.Assets;
import nme.display.Bitmap;
import nme.display.SimpleButton;
import nme.events.MouseEvent;
import nme.media.Sound;

/**
 * ...
 * @author BlueJack
 */

class ImageButton extends SimpleButton
{
	private var overSound:Sound;
	private var clickSound:Sound;

	public function new(btnName:String) {
		super();
		var path:String = "ui/" + btnName + "_1.png";	//upState file name
		upState = new Bitmap(Assets.getBitmapData(path));
		path = "ui/" + btnName + "_2.png";	//overState file name
		overState = new Bitmap(Assets.getBitmapData(path));
		downState = hitTestState = upState;
		overSound = Assets.getSound("sound/button-over.mp3");
		clickSound = Assets.getSound("sound/button-click.mp3");
		addEventListener(MouseEvent.MOUSE_OVER, onOver);
		addEventListener(MouseEvent.CLICK, onClick);
	}
	
	private function onClick(e:MouseEvent):Void {
		clickSound.play(0, 1);
	}
	
	private function onOver(e:MouseEvent):Void {
		overSound.play(0, 1);
	}
	
}